<?php
	/*
	 * Copyright 2009 Douglas Lockamy, dlockamy_at_gmail.com
	 * All rights reserved. Distributed under the terms of the MIT License.
	 */
/*
		 vfs spec
		 
		 FS File Types:
		 1 Directory
		 2 Text File
		 3 Binary File
		 4 Symlink
		 5 Mount Point
		 
		 FS File Read Flags
		 1 Request Type
		 2 Return Array of File in Directory
		 3 Read text/data file
		 
*/
	
	require('lib/SupportKit.php');
	
function vfs_lister ($directory) 
{
	$handle = opendir($directory);
	while ($file = readdir($handle)) 
	{
		if( $directory == '/')
		{
			if ($file != '.' && $file != '..' && $file != '.DS_Store' && $file != '.svn'&& $file != O)
			{
				if(filetype($directory.$file)=="dir" )
				{
					echo $file."@,";
				}
				else if(filetype($directory.$file)!="dir" )
				{
					echo $file."#,";
				}
				else
					echo "FAIL";
			}	
		}
		else if ($file != '.' && $file != '..' && $file != '.DS_Store' && $file != '.svn'&& $file != O)
		{
				if(filetype($directory."/".$file)=="dir" )
				{
					echo $file."@,";
				}
				else if(filetype($directory."/".$file)!="dir" )
				{
					echo $file."#,";
				}
				else
					echo "FAIL";
		}
	}
	closedir($handle);	
};

function vfs_read($path,$flags)
{
	$handle = opendir($directory);
	
	if(filetype($path)=="dir" )
	{
		echo $file."@,";
	}
	else if($flags==3)
	{
		printFileMIME($path);		
		echo file_get_contents($path);
	}
	else if($flags==4)
	{
		echo file_get_contents($path);
	}
};

function vfs_unlink($path)
{
	
	echo "delete file ".$path;
};
	
function vfs_creatdir($path,$target)
{
		echo "create dir ".$path;	
};
	
function vfs_creatlink($path,$target)
{
	echo "create dir ".$path;	
};
	
function vfs_write($path,$flags)
{
		echo "0";
		return;
		$handle = opendir($directory);
		
		if(filetype($path)=="dir" )
		{
			echo $file."@,";
		}
		else
		{
			echo readfile($path);
		}
};